package com.atguigu.gmall.user.controller;

import com.atguigu.gmall.common.util.AuthContextHolder;
import com.atguigu.gmall.model.user.UserAddress;
import com.atguigu.gmall.user.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 用户管理
 */
@RestController
@RequestMapping("/api/user/")
public class UserApiController {

    @Autowired
    private UserInfoService userInfoService;

    //内部资源 查询用户地址集合
    @GetMapping("/inner/getUserAddressList")
    public List<UserAddress> getUserAddressList(HttpServletRequest request){
        String userId = AuthContextHolder.getUserId(request);
        return userInfoService.getUserAddressList(userId);
    }

}
